package com.usian.comment.controller;

import com.usian.apis.comment.ApCommentConrollerApi;
import com.usian.comment.service.ApCommentService;
import com.usian.model.comment.dtos.CommentDto;
import com.usian.model.comment.dtos.CommentLikeDto;
import com.usian.model.comment.dtos.CommentSaveDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class ApCommentController implements ApCommentConrollerApi {
    @Autowired
    private ApCommentService apCommentService;

    @Override
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return apCommentService.saveComment(dto);
    }

    /***
     * 保存用户对评论的点赞 取消点赞
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/like")
    public ResponseResult like( @RequestBody CommentLikeDto dto) {
        return apCommentService.like(dto);
    }

    @Override
    @PostMapping("/load")
    public ResponseResult findByArticleId(CommentDto dto) {
        return apCommentService.findByArticleId(dto);
    }
}
